package com.example.administrator.printoutindemo;

import android.content.Context;


import com.example.administrator.printoutindemo.database.SQLiteDBService;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class OutStorageListMaterialInfo implements Serializable {
    private int _mid;
    private String _real_count;
    private String _projectname;
    private String _material;
    private String materialCode;//编码
    private String _unit;
    private String _supplier;
    private String _proid;
    private String storename;//仓库名称
    private String spacename;//仓位名称

    public String getMaterialCode() {
        return materialCode;
    }

    public void setMaterialCode(String materialCode) {
        this.materialCode = materialCode;
    }

    public String getStorename() {
        return storename;
    }

    public void setStorename(String storename) {
        this.storename = storename;
    }

    public String getSpacename() {
        return spacename;
    }

    public void setSpacename(String spacename) {
        this.spacename = spacename;
    }

    private SQLiteDBService sqliteDBservice;

    public OutStorageListMaterialInfo() {

    }

    public OutStorageListMaterialInfo(Context context) {
        sqliteDBservice = new SQLiteDBService(context);
    }


    // 将JSON对象转化为list
    public List<OutStorageListMaterialInfo> getListFromJSON(String JsonStr) {
        List<OutStorageListMaterialInfo> clist = new ArrayList<OutStorageListMaterialInfo>();

        try {

            JSONArray jay = new JSONArray(JsonStr);// 将字符串转化为JSON数组

            for (int i = 0; i < jay.length(); i++) {
                JSONObject temp = (JSONObject) jay.get(i);

                OutStorageListMaterialInfo n = new OutStorageListMaterialInfo();

                n.set_mid(temp.getInt("mid"));
                n.set_material(temp.getString("material"));
                n.set_proid(temp.getString("proid"));
                n.set_projectname(temp.getString("projectname"));
                n.set_real_count(temp.getString("real_count"));
                n.set_unit(temp.getString("unit"));
                n.set_supplier(temp.getString("supplier"));
                n.setStorename(temp.getString("storename"));
                n.setSpacename(temp.getString("spacename"));
                n.setMaterialCode(temp.getString("materialCode"));

                clist.add(n);

            }

        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }

        return clist;

    }

    public int get_mid() {
        return _mid;
    }

    public void set_mid(int _mid) {
        this._mid = _mid;
    }

    public String get_real_count() {
        return _real_count;
    }

    public void set_real_count(String _real_count) {
        this._real_count = _real_count;
    }

    public String get_projectname() {
        return _projectname;
    }

    public void set_projectname(String _projectname) {
        this._projectname = _projectname;
    }

    public String get_material() {
        return _material;
    }

    public void set_material(String _material) {
        this._material = _material;
    }

    public String get_unit() {
        return _unit;
    }

    public void set_unit(String _unit) {
        this._unit = _unit;
    }

    public String get_supplier() {
        return _supplier;
    }

    public void set_supplier(String _supplier) {
        this._supplier = _supplier;
    }

    public String get_proid() {
        return _proid;
    }

    public void set_proid(String _proid) {
        this._proid = _proid;
    }

}